// HJ71 字符串通配符
// https://www.nowcoder.com/practice/43072d50a6eb44d2a6c816a283b02036
//第六十九题  字符串通配符

#include <iostream>
#include <string>
#include <vector>
using namespace std;
// match wildcard 通配符
int match_string(string m_str, string w_str) {
  int m_len = m_str.size();
  int w_len = w_str.size();
  vector<vector<int> > b_dp(w_len + 1, vector<int>(m_len + 1, 0));
  //多加一行一列作为初始初值所用
  b_dp[0][0] = 1;
  for (int i = 1; i <= w_len; i++) {
    char ch = w_str[i - 1];
    // 设置每次循环的初值，即当星号不出现在首位时，匹配字符串的初值都为false
    b_dp[i][0] = b_dp[i - 1][0] && (ch == '*');
    for (int j = 1; j <= m_len; j++) {
      char ch2 = m_str[j - 1];
      if (ch == '*')
        b_dp[i][j] =
            b_dp[i - 1][j] ||
            b_dp[i]
                [j - 1];  //当匹配字符为*号时，状态取决于上面状态和左边状态的值
      else
        b_dp[i][j] = b_dp[i - 1][j - 1] &&
                     (ch == '?' || ch2 == ch);  //决定于上一次和本次
    }
  }
  return b_dp[w_len][m_len];
}
int main() {
  string str1, str2;
  while (cin >> str1 >> str2) {
    int rst = match_string(str2, str1);
    if (rst == 1)
      cout << "true" << endl;
    else
      cout << "false" << endl;
  }
}

/ 啊 / include<bits / stdc++.h> using namespace std;
bool is_character(char c) {
  //判断是否为字符
  if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
      (c >= '0' && c <= '9'))
    return true;
  else
    return false;
}

int main() {
  string s1, s2;
  while (cin >> s1 >> s2) {
    int len1 = s1.length() + 1, len2 = s2.length() + 1;
    bool dp[len1][len2];
    for (int i = 0; i < len1; i++) dp[0][i] = false;
    for (int i = 0; i < len2; i++) {
      dp[i][0] == true;
      for (int j = 0; j < i && j < len1 - 1; j++) {
        if (s1[j] != '') {
          dp[i][0] == false;
          break;
        }
      }
    }  //进行dp的初始化
    //需要判断s1是否是从第一位开始就全都是*如果不是就设置为false
    dp[0][0] = true;
    for (int i = 1; i < len1; i++) {
      for (int j = 1; j < len2; j++) {
        if (s1[i - 1] == '') {            //如果s1该位置为*
          if (is_character(s2[j - 1])) {  //判断s2该位置是否为字符
            dp[i][j] = dp[i - 1][j] || dp[i][j - 1];
          }  //如果是字符则可以表示0或任意个字符
          else {
            dp[i][j] = dp[i - 1][j];
          }  //如果不是字符只能表示空
        } else if (s1[i - 1] == '?') {
          //如果s1该位置为？
          if (is_character(s2[j - 1])) {
            //判断s2该位置是否为字符
            dp[i][j] = dp[i - 1][j - 1];
          } else {
            dp[i][j] = false;
          }
        } else {
          dp[i][j] = dp[i - 1][j - 1] && (s1[i - 1] == s2[j - 1]);
        }
      }
    }
    if (dp[len1 - 1][len2 - 1]) {
      cout << "true" << endl;
    } else {
      cout << "false" << endl;
    }
  }
}
